﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TS.Bussiness;
using TS.Commons;
using TS.Entities;

namespace Tranco
{
    public partial class GatewayDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                if (Session["TracoUserId"] == null)
                {
                    ClientAlert("Đăng nhập để xem thông tin lịch trình.");
                    return;
                }
                HiddenFieldId.Value = Request.QueryString["gwid"];

                LoadGateWay();
            }

        }


        private void LoadGateWay()
        {
            GatewayBussiness bu = new GatewayBussiness();
            Gateway gw = bu.GetGatewayById(HiddenFieldId.Value.ToNumeric());

            if (gw != null)
            {
                txtName.Text = gw.Name;
                txtDetails.Text = gw.Details;
                txtDescription.Text = gw.Description;
            }

        }
        public void ClientAlert(string strAlert)
        {
            var strScript = new StringBuilder();
            strScript.Append("<script language=JavaScript>");
            string scriptString = string.Format(CultureInfo.CurrentCulture, @"window.alert('" + strAlert + "');</script> ");
            strScript.Append(scriptString);
            ClientScript.RegisterStartupScript(GetType(), "Pop", strScript.ToString());
        }
    }
}